<?php
$allowImageType = ['jpeg' => 2000000, 'jpg' => 2000000, 'png' => '2000000'];
$file = 'aaa.txt';
$ext =  strtolower(pathinfo($file, PATHINFO_EXTENSION));
// array_key_exists判断数组中是否有某个key
$bool = array_key_exists($ext, $allowImageType);
if (!$bool) {
    echo 'wrong';
}
$types = ['jpg', 'png', 'gif'];
// in_array判断数组中是否有某个值
if (!in_array($ext, $types)) {
    echo '不允许的类型';
}
// array_keys获取数组的所有键所构成的数组
if (!in_array($ext, array_keys($allowImageType))) {
    echo '出错了';
}